'''
1、产生10个1-20的随机数，去除里面的重复项
2、键盘输入一个元素，将此元素从不重复的集合中删除
'''
'''
import random
list1 = []

for i in range(10):
	ran = random.randint(1,20)
	list1.append(ran)
	
set1 = set(list1)
print(list1)
print(set1)
while True:
	num = input('请输入一个数字：')
	if num.isdigit():
		num = int(num)
		break
	else:
		print('输入错误！请重新输入！')
		
set1.discard(num)
print('after discard')
print(set1)
'''


set1 = {1,2,3,4,5,6,7}
set2 = {1,2,3,5,6,9,8,7,10}
print('set1',set1)
print('set2',set2)
# & 交集  intersection
set3 = set1 &set2
set4 = set1.intersection(set2)
print('交集')
print(set3)
print(set4)

# - 差集  difference
set5 = set2 - set1
set6 = set2.difference(set1)
print('差集')
print(set5)
print(set6)

# | 并集  union()
set8 = set1 | set2
set7 = set2.union(set1)
print('并集')
print(set7)
print(set8)

# 对称差集
set9 = (set1 | set2) - (set1 & set2)
set10 = set1 ^ set2
print('对称差集')
print(set9)
print(set10)



print('\n\n')
print('set为可变类型')
print(id(set1))
set1.discard(5)
print('删除一个元素之后的请况')
print(id(set1))



fset = frozenset({3,6,8})
print(fset,id(fset))
fset = frozenset({3,6})
print(fset,id(fset))
